package com.dragon.mmochat.message;

import com.dragon.mmochat.MmochatConstant;
import com.dragon.mmochat.model.enumType.MmochatServerStateType;
import com.skymobi.buffer.SkymobiBuffer;
import com.skymobi.message.SkymobiModuleMessage;

public class Mmochat_ServerStateMessage extends SkymobiModuleMessage {
	private int instanceId;
	private MmochatServerStateType state;
	private String stateMsg;

	public Mmochat_ServerStateMessage() {
		setDstId(MmochatConstant.serverListModuleId);
		setMsgCode(MmochatConstant.MSGCODE_MMOCHAT_S_1_19);
	}

	@Override
	protected void decodeBody(SkymobiBuffer in) {
		instanceId = in.getInt();
		state = MmochatServerStateType.get(in.getInt());
		stateMsg = in.getPrefixedString(2);
	}

	@Override
	protected void encodeBody(SkymobiBuffer out) {
		out.putInt(instanceId);
		out.putInt(state.getKey());
		out.putPrefixedString(stateMsg, 2);
	}

	public MmochatServerStateType getState() {
		return state;
	}

	public void setState(MmochatServerStateType state) {
		this.state = state;
	}

	public String getStateMsg() {
		return stateMsg;
	}

	public void setStateMsg(String stateMsg) {
		this.stateMsg = stateMsg;
	}

	public int getInstanceId() {
		return instanceId;
	}

	public void setInstanceId(int instanceId) {
		this.instanceId = instanceId;
	}

}
